#ifndef _FONT_H
#define _FONT_H

#include <GL\glew.h>

#include <ft2build.h>
#include <freetype/freetype.h>
#include <freetype/ftglyph.h>
#include <freetype/ftoutln.h>
#include <freetype/fttrigon.h>

#include "StringUtils.h"
#include "Logger.h"
#include "Texture.h"
#include "Shader.h"
#include "Matrix4.h"
#include "Vector3.h"
#include "MathUtils.h"
#include "Vector2.h"
#include "Quaternion.h"
#include "Colour.h"

#ifdef GALLIUMENGINE_DLL 
#define GALLIUMENGINE_API __declspec( dllexport )
#else
#define GALLIUMENGINE_API __declspec( dllimport )
#endif

namespace GalliumEngine
{
	class ResourceManager;

	class Font
	{
	public:
		GALLIUMENGINE_API Font();
		GALLIUMENGINE_API ~Font();

		GALLIUMENGINE_API bool loadFont(std::string file, int iPXSize);
		GALLIUMENGINE_API int getTextWidth(std::string text, int iPXSize);
		GALLIUMENGINE_API void print(std::string sText, int x, int y, float z, int iPXSize, Colour colour, Matrix4 view, Matrix4 projection);
		GALLIUMENGINE_API void releaseFont();
		GALLIUMENGINE_API void bind();

	private:
		GLuint vertexbuffer;
		GLuint uvbuffer;

		std::vector<Vector3> vertices;
		std::vector<Vector2> uvs;

		std::vector<BindParams> params;

		void createChar(int iIndex);

		Texture tCharTextures[256];
		int iAdvX[256], iAdvY[256];
		int iBearingX[256], iBearingY[256];
		int iCharWidth[256], iCharHeight[256];
		int loadedPixelSize, iNewLine;

		bool loaded;

		FT_Library ftLib;
		FT_Face ftFace;
		Shader* shader;
	};

}

#endif